package cn.smile.config.home;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import cn.smile.constant.RuntimeConstant;
import cn.smile.interceptor.home.HomeGlobalInterceptor;
import cn.smile.interceptor.home.HomeLoginInterceptor;

import javax.annotation.Resource;

/**
 * 用来配置拦截器的配置类
 */
@Configuration
public class HomeWebConfig implements WebMvcConfigurer {

    @Resource
    private HomeLoginInterceptor homeLoginInterceptor;

    @Resource
    private HomeGlobalInterceptor homeGlobalInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(homeLoginInterceptor).addPathPatterns("/**").excludePathPatterns(RuntimeConstant.homeLoginExcludePathPatterns);
        registry.addInterceptor(homeGlobalInterceptor).addPathPatterns("/**").excludePathPatterns(RuntimeConstant.homeGlobalExcludePathPatterns);
    }

}
